//package com.cong.websocketdemo.config;
//
//import ch.qos.logback.classic.spi.ILoggingEvent;
//import ch.qos.logback.classic.spi.IThrowableProxy;
//import ch.qos.logback.core.filter.Filter;
//import ch.qos.logback.core.spi.FilterReply;
//import com.cong.websocketdemo.common.LoggerQueue;
//import com.cong.websocketdemo.pojo.LoggerMessage;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.text.DateFormat;
//import java.util.Date;
//
//@Service("logg")
//public class LogFilter extends Filter<ILoggingEvent> {
////
////    @Autowired
////    private ResultHandler handler;
//
//    //获取logback的日志，塞入日志队列中
//    @Override
//    public FilterReply decide(ILoggingEvent event) {
//        String exception = "";
//        IThrowableProxy iThrowableProxy1 = event.getThrowableProxy();
//        if (iThrowableProxy1 != null) {
//            exception = "<span class='excehtext'>" + iThrowableProxy1.getClassName() + " " + iThrowableProxy1.getMessage() + "</span></br>";
//            for (int i = 0; i < iThrowableProxy1.getStackTraceElementProxyArray().length; i++) {
//                exception += "<span class='excetext'>" + iThrowableProxy1.getStackTraceElementProxyArray()[i].toString() + "</span></br>";
//            }
//        }
//        LoggerMessage loggerMessage = new LoggerMessage(
//                event.getMessage()
//                , DateFormat.getDateTimeInstance().format(new Date(event.getTimeStamp())),
//                event.getThreadName(),
//                event.getLoggerName(),
//                event.getLevel().levelStr,
//                exception,
//                ""
//        );
//        LoggerQueue.getInstance().push(loggerMessage);
//       // handler.add(loggerMessage);
//        return FilterReply.ACCEPT;
//    }
//}
//
